<template>
    <rx-dialog @handOk="onSave" :oktext="okText" btnalign="right" order="top" @cancel="cancel">
        <div v-if="currentName=='edit1' && id_!=null" slot="toolbar">
            <a-button type="primary" @click="onNext">
                {{i18n('isButton.nextStep','下一步') }}
            </a-button>
        </div>
        <div v-if="currentName=='edit2'" slot="toolbar">
            <a-button class="toolbuton" type="primary" @click="onBefore">
                {{i18n('isButton.previousStep','上一步') }}
            </a-button>
        </div>
        <rx-layout>
            <div slot="center">
                <comment ref="current" :is="currentView" :pkId="id_" :layerid="layerid" :destroy="destroy"></comment>
            </div>
        </rx-layout>
    </rx-dialog>
</template>
<script>
import {RxDialog,Util} from "@lowcode/jpaas-common-lib";
import FormCalendarViewEdit1 from './FormCalendarViewEdit1'
import FormCalendarViewEdit2 from './FormCalendarViewEdit2'
export default {
    name: 'FormCalendarViewEdit',
    props:["pkId","layerid","destroy"],
    components: {
        RxDialog,
        FormCalendarViewEdit1,
        FormCalendarViewEdit2
    },
    data() {
        return {
            id_:this.pkId,
            okText:this.i18n('isButton.saveAndNextStep','保存&下一步') ,
            currentName:"edit1",
            currentView:FormCalendarViewEdit1,

        }
    },
    methods: {
        i18n(name,text,key){
            return this.$ti18(name,text,"FormCalendarView",key);
        },
        onNext(){
            this.currentView=FormCalendarViewEdit2;
            this.currentName="edit2";
            this.okText=this.i18n('isButton.saveAndPreview','保存&预览') ;
        },
        onBefore(){
            this.currentView=FormCalendarViewEdit1;
            this.currentName="edit1";
            this.okText=this.i18n('isButton.saveAndNextStep','保存&下一步');
        },
        onSave(vm,callback){
            this.currentView.methods.handleSubmit(this,this.$refs.current,callback);
            vm.loading =false;
        },
        cancel(){
            Util.closeWindow(this,"cancel");
        },
    }
}
</script>
<style>
.relick a {
    margin-right: 10px;
}

</style>
